//
//  RegisteredViewController.m
//  10-10
//
//  Created by 钟纪旺 on 16/10/27.
//  Copyright © 2016年 zjw. All rights reserved.
//

#import "RegisteredViewController.h"
#import "LoginData.h"
#import "ObtainData.h"
#import "DengLu.h"
#import "Network.h"
@interface RegisteredViewController ()

@property (weak, nonatomic) IBOutlet UITextField *tel;
@property (weak, nonatomic) IBOutlet UITextField *name;
@property (weak, nonatomic) IBOutlet UITextField *password;

@end

@implementation RegisteredViewController



- (IBAction)registered:(id)sender {
    
    
    
    [Network loginWithName:self.name.text password:self.password.text tel:self.tel.text complete:^(LoginData *  d){
        LoginData *ata = d;
        
        // GCD 大中枢派发
        dispatch_async(dispatch_get_main_queue(), ^{
            // 刷新界面代码
            
                           HUD = [[MBProgressHUD alloc] initWithView:self.view];
                [self.view addSubview:HUD];
                HUD.labelText =@"恭喜您注册成功!";
                HUD.mode = MBProgressHUDModeText;
                [HUD showAnimated:YES whileExecutingBlock:^{
                    sleep(2);
                }completionBlock:^{
                    [HUD removeFromSuperview];
                    HUD =nil;
                    DengLu *con = [self.storyboard instantiateViewControllerWithIdentifier:@"dddd"];
                    //推进去
                    [self presentViewController:con animated:YES completion:^{
                        
                    }];
                    
                }];
                
            
        });
    }];
    
    
    }



- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    UIToolbar *tobView = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,44)];
    [tobView setBarStyle:UIBarStyleBlack];
    UIBarButtonItem *button1 = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
    UIBarButtonItem *button2 =[[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:nil action:nil];
    UIBarButtonItem* doneButton = [[UIBarButtonItem alloc]initWithTitle:@"完成"style:UIBarButtonItemStyleDone target:self action:@selector(endEdit)];
    NSArray* buttonsArray = [NSArray arrayWithObjects:button1,button2,doneButton,nil];
    [tobView setItems:buttonsArray];
    [self.tel setInputAccessoryView:tobView];
    [self.name setInputAccessoryView:tobView];
    [self.password setInputAccessoryView:tobView];
}
-(void)endEdit{

 [self.view endEditing:YES];

}
- (void) touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    
    [self.view endEditing:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
